import 'package:flutter/material.dart';
import 'package:didiboji/bean/Beans.dart';
import 'package:didiboji/bean/Settings.dart';
import 'package:color/color.dart';
class AlertList extends StatelessWidget {
  final List<Alert> alerts;
  AlertList({this.alerts,});
  @override
  Widget build(BuildContext context) {
    return new ListView(
      children: alerts.map(
        (alert){
          return new Card(
            elevation: 10.0,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(4.0)),
              side: BorderSide(
                width: 1.0,
                color: Colors.black45
              )
            ),
            child: new Container(
              decoration: BoxDecoration(
                color: Colors.black87
              ),
              child: new Row(
                children: <Widget>[
                  new Image.network(
                    alert.missionRewardItemThumbnail,
                    width: 100.0,
                    height: 100.0,
                  ),
                  new Column(
                    children: <Widget>[
                      new Text.rich(
                        new TextSpan(
                          text: alert.missionNode,
                          style: new TextStyle(
                            color: Theme.of(context).primaryColor,
                            fontSize: 20.0 
                          ),
                          children: <TextSpan>[
                            new TextSpan(text: "\n"),
                            new TextSpan(
                              text: alert.missionType + ' ',
                              style: new TextStyle(
                                color: Colors.amber,
                                fontSize: 14.0 
                              ),
                              children: <TextSpan>[
                                new TextSpan(
                                  text: alert.missionFaction,
                                  style: new TextStyle(
                                    color: Colors.orange,
                                    fontSize: 14.0,
                                  ) 
                                )
                              ] 
                            )
                          ] 
                        )
                      ),
                      new Text.rich(
                        new TextSpan(
                          text: '敌人等级 ',
                          style: TextStyle(
                            color: Colors.white70
                          ),
                          children: <TextSpan>[
                            new TextSpan(
                              text: alert.missionMinEnemyLevel.toString(),
                              style: TextStyle(color:Colors.orangeAccent),
                            ),
                            new TextSpan(
                              text: ' - ',
                              style: TextStyle(color:Colors.orangeAccent),
                            ),
                            new TextSpan(
                              text: alert.missionMaxEnemyLevel.toString(),
                              style: TextStyle(color:Colors.orangeAccent),
                            ),
                          ] 
                        ) 
                      ),
                      new Text.rich(new TextSpan(
                        text: '任务现金 ',
                        style: TextStyle(
                          color: Colors.white70
                        ),
                        children: <TextSpan>[
                          new TextSpan(
                            text: alert.missionRewardCredits.toString(),
                            style: TextStyle(color:Colors.orangeAccent),
                          )
                        ]
                      )),
                      new Text.rich(new TextSpan(
                        text: '任务奖励 ',
                        style: TextStyle(
                          color: Colors.white70
                        ),
                        children: <TextSpan>[
                          new TextSpan(
                            text: alert.missionRewardItemString.toString(),
                            style: TextStyle(color:Colors.orangeAccent),
                          )
                        ]
                      )),
                      
                      alert.missionArchwingRequired || alert.missionNightMare ?
                      new Text.rich(new TextSpan(
                        text: '特殊需求 ',
                        style: TextStyle(
                          color: Colors.white70
                        ),
                        children: <TextSpan>[
                            new TextSpan(
                            text: alert.missionArchwingRequired ? "Archwing " : ' 噩梦',
                            style: TextStyle(
                              color: alert.missionNightMare ? Colors.red : Colors.orange.shade800 
                            ),
                            children: <TextSpan>[
                              alert.missionArchwingRequired && alert.missionNightMare ? new TextSpan(
                                text: '噩梦',
                                style: TextStyle(color: Colors.red)
                              ):new TextSpan()
                            ] 
                          ) 
                        ] 
                      )):new Text.rich(new TextSpan()),
                      new Text.rich(new TextSpan(
                        text: "剩余 ",
                        style: TextStyle(color: Colors.white70),
                        children: <TextSpan>[
                          new TextSpan(
                            text: alert.eta,
                            style: new TextStyle(
                              color:Colors.orangeAccent
                            )
                          )
                        ]
                      ))
                    ],   
                  )
                ],  
              ),
            ),
          );
        }
      ).toList()
    );
  }
}